import { createRouter, createWebHistory } from 'vue-router'
import Login from '../components/Login.vue'
import ArticleList from '../components/Articles.vue'
import CreateArticle from '../components/CreateArticle.vue'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView  // 设置根路径为 HomeView
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/articles',
      name: 'articles',
      component: ArticleList
    },
    {
      path: '/article/create',
      name: 'createArticle',
      component: CreateArticle
    },
    {
      path: '/article/:id',
      name: 'articleDetail',
      component: () => import('../components/ArticleDetail.vue')
    },
    {
      path: '/article/edit/:id',
      name: 'articleEdit',
      component: () => import('../components/EditArticle.vue')
    }
  ]
})

export default router